<template>
    <div>
        <el-alert>演示数据库采用内存数据库，每次重启后数据都会重置</el-alert>
        <div style="margin-top: 10px;margin-bottom: 10px;">
            <el-button @click="init" type="primary">刷新</el-button>
        </div>
        <el-tabs>
            <el-tab-pane label="用户表">
                <el-table :data="user" border>
                    <el-table-column type="index"/>
                    <el-table-column prop="username" label="用户名"/>
                    <el-table-column prop="password" label="密码"/>
                </el-table>
            </el-tab-pane>
            <el-tab-pane label="系统设置表">
                <el-table :data="setting" border>
                    <el-table-column type="index"/>
                    <el-table-column prop="key" label="变量名"/>
                    <el-table-column prop="value" label="变量值"/>
                </el-table>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
    import ws from "./socket/socket"
    export default {
        name: "db-manage",
        data(){
            return {
                user: [],
                setting: []
            }
        },
        methods:{
            async init(){
                var r = await ws.send("REQ_DB_LIST")
                this.user = r.user||[]
                this.setting = r.setting||[]
            }
        },
        mounted() {
            this.init()
        }
    }
</script>

<style scoped>

</style>
